#coding:utf-8
import time
import logging
import logging.config
from VSTestPro.API.Instruments.DMM.gdm8261a import GDM8261A
from VSTestPro.API.Instruments.PowerSupply.gwinstek import GWinstek

logging.config.fileConfig("logger.conf")

dmm = GDM8261A(serial="COM6")
pwr = GWinstek(gpib_addr=8)

print pwr.getid()
print dmm.getid()

pwr.clear()
dmm.clear()

pwr.setV(1, 0, 0.5)
pwr.outOn()

logger = logging.getLogger("pwrdmm")
# logger.info("Current test begin")

# set voltage from 3.6V to 3.0V ,0.2V a step,watch current in 1 hour
for i in range(36,30,-2):
    i/=10
    pwr.setV(1, i, 0.5)
    pwr.outOn()
    logging.debug("The voltage now is %s" %i)
    t=3600
    while t > 0:
        t -= 1
        time.sleep(1)
        pI = dmm.getI()
        logging.debug('The current now is %s' % pI)
